//
//  LrcParser.m
//  04UI-HomeWork
//
//  Created by 冀永金 on 16/7/21.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "LrcParser.h"

@implementation LrcParser
- (instancetype)init {
    self = [super init];
    if (self) {
        self.timeArray = [NSMutableArray array];
        self.wordArrary = [NSMutableArray array];
    }
    return self;
}
-(void)parseLrc {
    NSString *path = [[NSBundle mainBundle]pathForResource:@"稻香" ofType:@"lrc"];
    NSURL *url = [NSURL fileURLWithPath:path];
    // 转换字符串
    NSString *lrc = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
   // NSLog(@"%@",lrc);
    if (![lrc isEqual:nil]) {
        NSArray *sepArray = [lrc componentsSeparatedByString:@"["];
        NSArray *lineArray = [NSArray array];
        for (int i = 0; i < sepArray.count; i++) {
            if ([sepArray[i] length] > 0) {
                lineArray = [sepArray[i] componentsSeparatedByString:@"]"];
                if (![lineArray[0] isEqualToString:@"\n"]) {
                    [self.timeArray addObject:lineArray[0]];
                    [self.wordArrary addObject:lineArray.count > 1 ? lineArray[1] : @""];
                }
            }
        }
        
        
    }
    NSLog(@"%@",self.wordArrary);
    
}
@end
